<?php
/*
 * @Author: your name
 * @Date: 2020-12-23 12:01:16
 * @LastEditTime: 2020-12-28 10:17:55
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: /special/application/common/service/ServerDownload.php
 */

namespace app\common\service;


use think\Db;

class ServerDownload extends BaseService
{
    /**
     * @name 列表
     * @param $module
     * @return array
     * @author wx
     * @date 2019/11/4 14:15
     */
    public function list($module)
    {
        $db = Db::name('server_download');
        $list = $db->field('id, ctime, path, ratio, status')
            ->where('module', $module)
            ->order('id desc')
            ->paginate()->toArray();

        return $list;
    }

    /**
     * @name 查询
     * @param $condition
     * @return array|null|\PDOStatement|string|\think\Model
     * @author wx
     * @date 2019/11/4 14:16
     */
    public function findData($condition, $field = '*')
    {
        return Db::name('server_download')->field($field)->where($condition)->find();
    }

    /**
     * @name 修改状态
     * @param $module
     * @param $id
     * @return int|string
     * @author wx
     * @date 2019/11/4 14:58
     */
    public function del($id)
    {
        return Db::name('server_download')->where('id','in',$id)->delete();
    }

    public function add($addData)
    {
        return Db::name('server_download')->insertGetId($addData);
    }

    public function modify($condition, $updateData)
    {
        return Db::name('server_download')->where($condition)->update($updateData);
    }
}